<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <h2><a href="#" class="back" onclick="history.go(-1)"/>Visualizar Empresa</h2>
        </ui:define>

        <ui:define name="body">

            <p:panel styleClass="container_24 clearfix">
                <div class="buttonAction" style="float: right">
                    <p:button value="Editar" href="editarempresa.xhtml?eEmpresa=#{managerPesquisarEmpresa.empresaVisualizar.id}" 
                              icon="ui-icon-pencil" styleClass="ui-priority-primary"/>
                </div>
            </p:panel>

            <h:form id="empresaForm" enctype="multipart/form-data">            
                <p:messages id="messages" closable="true" showDetail="false" autoUpdate="true"  />

                <p:panel id="empresaPanel" styleClass="container_24 clearfix" >
                    <h2>Empresa</h2><br/>

                    <p:focus for="cnpjInputText"/>
                    <p:outputLabel value="CNPJ:" styleClass="grid_3" for="cnpjInputText"/>
                    <p:inputMask id="cnpjInputText" value="#{managerPesquisarEmpresa.empresaVisualizar.cnpj}" 
                                 styleClass="grid_8" mask="99.999.999/9999-99"
                                 autocomplete="false" readonly="true" />
                    <div class="clear"/>

                    <p:outputLabel value="Razão Social:" styleClass="grid_3" for="empresaInputText"/>
                    <p:inputText styleClass="grid_20" id="empresaInputText" readonly="true"
                                 value="#{managerPesquisarEmpresa.empresaVisualizar.nomeFantasia}"/>
                    <div class="clear"/>

                    <h2>Setores</h2>

                    <p:panel id="setorPanel" style="background: none; border: none; margin-left: -13px; padding-right: 0px; margin-right: 0px">
                        <p:dataTable id="setorTable" var="item" value="#{managerPesquisarEmpresa.empresaVisualizar.setores}" 
                                     styleClass="grid_24" emptyMessage="Nenhum registro" rowIndexVar="idsetor">  
                            <f:facet name="header">
                                Setores
                            </f:facet>

                            <p:column headerText="Nome" style="vertical-align: middle; text-align: center">
                                <h:outputText value="#{item.nome}"/>
                            </p:column>
                        </p:dataTable>
                    </p:panel>

                    <br/>

                    <h2>Usuários</h2>

                    <p:panel id="usuarioPanel" style="background: none; border: none; margin-left: -13px; padding-right: 0px; margin-right: 0px">
                        <p:dataTable id="empresaTable" var="item" value="#{managerPesquisarEmpresa.usuariosVisualizar}" 
                                     styleClass="grid_24" emptyMessage="Nenhum registro" rowIndexVar="idempresa">  
                            <f:facet name="header">
                                Usuários
                            </f:facet>

                            <p:column headerText="Nome" style="vertical-align: middle; text-align: center">
                                <h:outputText value="#{item.nome}"/>
                            </p:column>
                            <p:column headerText="E-mail" style="vertical-align: middle; text-align: center">
                                <h:outputText value="#{item.email}"/>
                            </p:column>
                            <p:column headerText="Contato(s)" style="vertical-align: middle; text-align: center">
                                <h:outputText value="#{item.telefone}"/><br/>
                                <h:outputText value="#{item.telefone2}"/>
                            </p:column>
                            <p:column headerText="Resposável legal" style="vertical-align: middle; text-align: center">
                                <h:outputText value="#{item.responsavelLegal ? 'Sim' : 'Não'}"/>
                            </p:column>

                        </p:dataTable>
                    </p:panel>

                    <div class="clear"/>

                    <h2>Endereço</h2>

                    <div class="clear"/><br/>

                    <p:outputLabel value="CEP:" styleClass="grid_3" for="cepInputMask" />
                    <p:inputMask  id="cepInputMask" styleClass="grid_9" mask="99.999-999"
                                  value="#{managerPesquisarEmpresa.enderecoVisualizar.cep}" 
                                  readonly="true" /> 

                    <p:outputLabel value="Número: " styleClass="grid_3" for="numInputText" />
                    <p:inputText id="numInputText" styleClass="grid_8" readonly="true"
                                 value="#{managerPesquisarEmpresa.enderecoVisualizar.numero}" />

                    <div class="clear"/>

                    <p:outputLabel value="Logradouro:" styleClass="grid_3" for="patioInputText" />
                    <p:inputText id="patioInputText" styleClass="grid_9" readonly="true"
                                 value="#{managerPesquisarEmpresa.enderecoVisualizar.logradouro}" />


                    <p:outputLabel value="Bairro: " styleClass="grid_3" for="bairroInputText" />
                    <p:inputText id="bairroInputText" styleClass="grid_8" readonly="true"
                                 value="#{managerPesquisarEmpresa.enderecoVisualizar.bairro}" />

                    <div class="clear"/>

                    <p:outputLabel value="Município: " styleClass="grid_3" for="municipioInputText" />
                    <p:inputText id="municipioInputText" styleClass="grid_9" readonly="true"
                                 value="#{managerPesquisarEmpresa.enderecoVisualizar.municipio}" />

                    <p:outputLabel value="Estado: " styleClass="grid_3 " for="estadoInputText" />
                    <p:inputText id="estadoInputText" styleClass="grid_8" readonly="true"
                                 value="#{managerPesquisarEmpresa.enderecoVisualizar.uf}" />

                    <div class="clear"/>

                    <p:outputLabel value="Complemento: " styleClass="grid_3" for="complementInputText" />
                    <p:inputText id="complementInputText" styleClass="grid_20" readonly="true"
                                 value="#{managerPesquisarEmpresa.enderecoVisualizar.compl}" />


                    <div class="clear"/><br/>
                    <div class="buttonAction">
                        <p:button value="Voltar" icon="ui-icon-circle-arrow-w"
                                  href="indexempresa.xhtml"/>
                    </div>

                </p:panel>
            </h:form>
            <script  type="text/javascript" src="media/js/autoNumeric.js"></script>
        </ui:define>
    </ui:composition>
</html>